using System;
using NUnit.Framework;

namespace ProgrammingLanguageNr1
{
	public class ReturnValue : Exception
	{
		public ReturnValue() {
			m_returnType = ReturnType.VOID;
		}
		
		public ReturnValue (string text)
		{
			this.StringValue = text;
			m_returnType = ReturnType.STRING;
		}
		
		public ReturnValue (float nr)
		{
			this.FloatValue = nr;
			m_returnType = ReturnType.FLOAT;
		}
		
		public float FloatValue {
			set {
				m_floatValue = value;
				m_returnType = ReturnType.FLOAT;
			}
			get {
				Assert.AreEqual(ReturnType.FLOAT, m_returnType);
				return m_floatValue;
			}
		}
		
		public string StringValue {
			set {
				m_stringValue = value;
				m_returnType = ReturnType.STRING;
			}
			get {
				Assert.AreEqual(ReturnType.STRING, m_returnType);
				return m_stringValue;
			}
		}
		
		public void setVoid() { m_returnType = ReturnType.VOID; }
		
		public ReturnValue getNewReturnValueConvertedToString() {
			return new ReturnValue(Convert.ToString(m_floatValue));
		}
		
		public ReturnType getReturnType() { return m_returnType; }
		
		ReturnType m_returnType = ReturnType.VOID;
		float m_floatValue;
		string m_stringValue;
	}
}

